using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace Skywave.IO.Compression
{
    /// <summary>
    /// Unique class for compression/decompression file. Represents a Zip file.
    /// </summary>
    public static class ZipStorerFile
    {
        private static ZipStorerProvider_File _Provider = new ZipStorerProvider_File();
        /// <summary>
        /// Method to create a new storage file
        /// </summary>
        /// <param name="_filename">Full path of Zip file to create</param>
        /// <param name="_comment">General comment for Zip file</param>
        /// <returns>A valid ZipStorer object</returns>
        public static async Task<ZipStorer> Create(string _filename, string _comment = "")
        {
            ZipStorer r = await ZipStorer.Create(_Provider, _filename, _comment);
            return r;
        }
        /// <summary>
        /// Method to create a new zip storage in a stream
        /// </summary>
        /// <param name="_stream"></param>
        /// <param name="_comment"></param>
        /// <returns>A valid ZipStorer object</returns>
        public static ZipStorer Create(Stream _stream, string _comment = "")
        {
            ZipStorer r = ZipStorer.Create(_Provider, _stream, _comment);
            return r;
        }
        /// <summary>
        /// Method to open an existing storage file
        /// </summary>
        /// <param name="_filename">Full path of Zip file to open</param>
        /// <param name="_access">File access mode as used in FileStream constructor</param>
        /// <returns>A valid ZipStorer object</returns>
        public static async Task<ZipStorer> Open(string _filename, bool isWriteAccess)
        {
            ZipStorer r = await ZipStorer.Open(_Provider, _filename, isWriteAccess);
            return r;
        }
        public static async Task<ZipStorer> Open(string _filename, FileAccess fileAccess)
        {
            ZipStorer r = await ZipStorer.Open(_Provider, _filename, (fileAccess == FileAccess.Read) ? false : true);
            return r;
        }
        /// <summary>
        /// Method to open an existing storage from stream
        /// </summary>
        /// <param name="_stream">Already opened stream with zip contents</param>
        /// <param name="_access">File access mode for stream operations</param>
        /// <returns>A valid ZipStorer object</returns>
        public static ZipStorer Open(Stream _stream, bool isWriteAccess)
        {
            ZipStorer r = ZipStorer.Open(_Provider, _stream, isWriteAccess);
            return r;
        }
        public static ZipStorer Open(Stream _stream, FileAccess fileAccess)
        {
            ZipStorer r = ZipStorer.Open(_Provider, _stream, (fileAccess == FileAccess.Read) ? false : true);
            return r;
        }
    }
}